package ajaxmethods;


import global.Global;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.json.JSONObject;


public class SessionMethod implements AjaxMethod {

	protected JSONObject data = new JSONObject();
	protected Global global;
	@Override
	public void perform(HttpServletRequest request, HttpServletResponse response) {
		response.setContentType("text/json");
		global = new Global(request);
		try {
		if(global.isLoggedIn.f(request))
			data = global.getUser().toJson();
		else
		{
			data.put("notloggedin", true);
		}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
